#ifndef _RATIONAL_H_
#define _RATIONAL_H_

class Rational {
	
	friend bool operator== (const Rational & a, const Rational & b);
	friend bool operator< (const Rational & a, const Rational & b);
	friend Rational operator- (const Rational & a);

public:
	explicit Rational (int a); 
	Rational (int a, int b);
	Rational (const Rational & a);
	Rational & operator= (const Rational & a); 
	Rational & operator+= (const Rational & a); 
	Rational & operator-= (const Rational & a); 
	Rational & operator*= (const Rational & a); 
	Rational & operator/= (const Rational & a); 
	Rational & operator++ ();
	Rational operator++ (int unused);
	Rational & operator-- ();
	Rational operator-- (int unused);
	operator double () const;

private:
	void swap (Rational & a);
	void cancel ();

private:
	int num;
	int den;
};

Rational operator+ (const Rational & a, const Rational & b);
Rational operator- (const Rational & a, const Rational & b);
Rational operator* (const Rational & a, const Rational & b);
Rational operator/ (const Rational & a, const Rational & b);

bool operator== (const Rational & a, const Rational & b);
bool operator!= (const Rational & a, const Rational & b);
bool operator<= (const Rational & a, const Rational & b);
bool operator>= (const Rational & a, const Rational & b);
bool operator<  (const Rational & a, const Rational & b);
bool operator>  (const Rational & a, const Rational & b);

#endif // _RATIONAL_H _
